# Hakix v1.0 is released under the General Public license (Please refer to GPL.txt)
# Written by frenchninja@gmail.com. See http://code.google.com/p/hakix
# Inspired by Automatix by arnieboy

import Pmw
import Tkinter
from Tkinter import *
import os, sys
import tkMessageBox

if os.geteuid() != 0:
    print "Sorry, you need to run this as root!"
    sys.exit(0) 

		#_____________________________________________________________________
class Hakix:
		#_____________________________________________________________________

    def about(self):
	self.about = tkMessageBox.showinfo("About Hakix", "Hakix Version 1.0\n\nWritten by frenchninja(@gmail.com)\n\nWebsite http://code.google.com/p/hakix\n\nhttp://frenchninja.wordpress.com\n\nIf pain persists, please see your doctor")
        
    def install(self):
        
        if self.gnome.get():
        	os.system('aptitude install desktop gnome-desktop')
        if self.kde.get():
        	os.system('aptitude install desktop kde-desktop')
        if self.xfce.get():
        	os.system('aptitude install desktop xfce-desktop')
        if self.gftp.get():
        	os.system('apt-get install gftp')
        if self.icedove.get():
        	os.system('apt-get install icedove icedove-gnome-support')
        if self.sylpheed.get():
        	os.system('apt-get install -y --assume-yes sylpheed-claws-gtk2 sylpheed-claws-gtk2-plugins')
        if self.abiword.get():
        	os.system('apt-get install -y --assume-yes abiword abiword-common abiword-plugins')
        if self.gdesklets.get():
        	os.system('apt-get install -y --assume-yes gdesklets gdesklets-data')
        if self.gnomebaker.get():
        	os.system('apt-get install -y --assume-yes gnomebaker')
        if self.k3b.get():
        	os.system('apt-get install -y --assume-yes k3b')
        if self.photo.get():
        	os.system('apt-get install -y -assume-yes kamera f-spot digikam kflickr')
        if self.beryl.get():
		os.system('echo "deb http://debian.beryl-project.org etch main" >> /etc/apt/sources.list')
		os.system('echo "deb-src http://debian.beryl-project.org etch main" >> /etc/apt/sources.list')
		os.system('wget http://debian.beryl-project.org/root@lupine.me.uk.gpg -O- | sudo apt-key add -')
		os.system('apt-get update')
        	os.system('apt-get install --assume-yes beryl beryl-core libberyldecoration0 libberylsettings0 beryl-manager beryl-plugins beryl-plugins-data beryl-settings emerald emerald-themes libemeraldengine0')
		os.system('cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup_preberyl')
		os.system('zenity --info --title "Xorg conf" --text \
		$"You just need to make a few small adjustments to your /etc/X11/xorg.conf to make Beryl work, as follows: \nAdd the lines under their respective Sections. \nThe last one is probably brand new, add it at the end of the file. \nSection \\"ServerLayout\\" \n    Option         \\"AIGLX\\" \\"true\\"\\ \nSection \\"Module\\" \n    Load            \\"dbe\\"\\ \nSection \\"Screen\\" \n    Option         \\"XAANoOffscreenPixmaps\\" \n    Option         \\"AddARGBGLXVisuals\\" \\"true\\"\\ \nSection \\"Device\\" \n    Option         \\"RenderAccel\\" \\"true\\"\\ \n    Option         \\"AllowGLXWithComposite\\" \\"true\\"\\ \nSection \\"Extensions\\" \n    Option         \\"Composite\\" \\"Enable\\" \nEndSection\n\nThat\'\s it! Restart and then run \\"beryl-manager\\" to switch to Beryl.\nBeryl can be switched off again by right-clicking the Beryl systray icon and changing the Window Manager to your preferred one (often Metacity for Gnome, KWin for KDE).\n\nReport any errors to frenchninja@gmail.com!"')
        if self.wine.get():
		os.system('apt-get install -y --assume-yes wine')
	if self.googleearth.get():
		os.system('wget http://dl.google.com/earth/GE4/GoogleEarthLinux.bin')
		os.system('sh GoogleEarthLinux.bin')
	if self.swiftfox.get():
		os.system('sh /usr/local/bin/hakix/conf/swiftfox')
	if self.opera.get():
		os.system('wget http://downloads.planetmirror.com/pub/opera/linux/910/final/en/i386/shared/opera_9.10-20061214.6-shared-qt_en_i386.deb')
		os.system('dpkg -i opera_9.10-20061214.6-shared-qt_en_i386.deb')
		os.system('rm opera_9.10-20061214.6-shared-qt_en_i386.deb')
	if self.konq.get():
		os.system('apt-get install -y --assume-yes konqueror konq-plugins')
	if self.flash9.get():
		os.system('apt-get install -y --assume-yes flashplugin-nonfree')
	if self.gftp.get():
		os.system('apt-get install -y --assume-yes gftp')
	if self.xchat.get():
		os.system('apt-get install -y --assume-yes xchat xchat-systray')
	if self.gaim.get():
		os.system('apt-get install -y --force-yes gaim gaim-data festival-gaim gaim-encryption gaim-extendedprefs gaim-guifications gaim-irchelper gaim-themes')
	if self.skype.get():
		os.system('wget http://www.skype.com/go/getskype-linux-deb')
		os.system('apt-get install -y --assume-yes gcc-3.3-base libstdc++5')
		os.system('dpkg -i skype_debian-1.3.0.53-1_i386.deb')
		os.system('rm skype_debian-1.3.0.53-1_i386.deb')
	if self.nicotine.get():
		os.system('apt-get install -y --assume-yes nicotine')
	if self.frostwire.get():
		os.system('wget http://fuse.frostwire.com/frostwire/4.13.1/frostwire-4.13.1.5-1.i586.deb')
		os.system('dpkg -i frostwire-4.13.1.5-1.i586.deb')
		os.system('rm frostwire-4.13.1.5-1.i586.deb')
	if self.azureus.get():
		os.system('apt-get install -y --assume-yes azureus')
	if self.java.get():
		os.system('xterm -e "DEBIAN_FRONTEND=gnome apt-get install -y --assume-yes sun-java5-plugin sun-java5-jre sun-java5-bin java-common"')
        if self.macro.get():
        	os.system('install -y --assume-yes flashplayer-mozilla')
	if self.myth.get():
		os.system('apt-get install -y --assume-yes mythtv mythplugins')
	if self.listen.get():
		os.system('apt-get install -y --assume-yes listen')
	if self.vlc.get():
		os.system('apt-get install -y --assume-yes vlc mozilla-plugin-vlc')
	if self.realplayer.get():
		os.system('apt-get install -y --assume-yes realplayer')
	if self.jokosher.get():
		os.system('apt-get install -y --assume-yes jokosher')
	if self.audacity.get():
		os.system('apt-get install -y --assume-yes audacity')
	if self.hydrogen.get():
		os.system('apt-get install -y --assume-yes hydrogen hydrogen-drumkits')
	if self.easytag.get():
		os.system('apt-get install -y --assume-yes easytag')
	if self.banshee.get():
		os.system('apt-get install -y --assume-yes banshee banshee-official-plugins')
	if self.xmms.get():
		os.system('apt-get install -y --assume-yes xmms xmms-skins xmms-status-plugin')
	if self.amarok.get():
		os.system('apt-get install -y --assume-yes amarok')
	if self.songbird.get():
		os.system('wget http://download.songbirdnest.com/installer/linux/i686/Songbird_0_2_5_linux-i686.tar.gz')
		os.system('tar xzvf Songbird_0_2_5_linux-i686.tar.gz')
		os.system('mv Songbird /usr/bin/')
		os.system('cp /usr/bin/Songbird/chrome/icons/default/default.xpm /usr/share/pixmaps/songbird.xpm')
		os.system('mv /usr/local/bin/hakix/conf/songbird.desktop /usr/share/applications/')
		os.system('rm Songbird_0_2_5_linux-i686.tar.gz')
	if self.libdvdcss.get():
		os.system('apt-get install -y --assume-yes libdvdcss2')
	if self.nvidia686.get():
		os.system('apt-get install -y --assume-yes nvidia-kernel-2.6-686 nvidia-kernel-common nvidia-glx nvidia-xconfig')
		os.system('nvidia-xconfig')
	if self.nvidia486.get():
		os.system('apt-get install -y --assume-yes nvidia-kernel-2.6-486 nvidia-kernel-common nvidia-glx nvidia-xconfig')
		os.system('nvidia-xconfig')
	if self.nvidiaK7.get():
		os.system('	apt-get install -y --assume-yes nvidia-kernel-2.6-k7 nvidia-kernel-common nvidia-glx nvidia-xconfig')
		os.system('nvidia-xconfig')
	if self.ati.get():
		os.system('apt-get install -y --assume-yes fglrx-control fglrx-driver fglrx-kernel-src module-assistant')
		os.system('m-a prepare')
		os.system('m-a update')
		os.system('m-a a-i fglrx')
		os.system('modprobe fglrx')
	if self.ppracer.get():
		os.system('apt-get install -y --assume-yes planetpenguin-racer')
	if self.fonts.get():
		os.system('apt-get install -y --assume-yes ttf-larabie-deco ttf-larabie-straight ttf-larabie-uncommon')
	if self.numlockx.get():
		os.system('apt-get install -y --assume-yes numlockx')
		os.system('cp /usr/local/bin/hakix/conf/Default /etc/gdm/Init/')

		#_____________________________________________________________________

    def __init__(self, parent):
        # Create and pack the NoteBook.
        notebook = Pmw.NoteBook(parent)
        notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        self.gnome = BooleanVar()
        self.kde = BooleanVar()
        self.xfce = BooleanVar()
        self.gftp = BooleanVar()
        self.icedove = BooleanVar()
        self.sylpheed = BooleanVar()
	self.abiword = BooleanVar()
	self.gdesklets = BooleanVar()
	self.gnomebaker = BooleanVar()
	self.k3b = BooleanVar()
	self.photo = BooleanVar()
	self.beryl = BooleanVar()
	self.wine = BooleanVar()
	self.googleearth = BooleanVar()
	self.swiftfox = BooleanVar()
	self.opera = BooleanVar()
	self.konq = BooleanVar()
	self.flash9 = BooleanVar()
	self.gftp = BooleanVar()
	self.xchat = BooleanVar()
	self.gaim = BooleanVar()
	self.skype = BooleanVar()
	self.nicotine = BooleanVar()
	self.frostwire = BooleanVar()
	self.azureus = BooleanVar()
	self.java = BooleanVar()
	self.macro = BooleanVar()
	self.myth = BooleanVar()
	self.listen = BooleanVar()
	self.vlc = BooleanVar()
	self.realplayer = BooleanVar()
	self.jokosher = BooleanVar()
	self.audacity = BooleanVar()
	self.hydrogen = BooleanVar()
	self.easytag = BooleanVar()
	self.banshee = BooleanVar()
	self.xmms = BooleanVar()
	self.amarok = BooleanVar()
	self.songbird = BooleanVar()
	self.libdvdcss = BooleanVar()
	self.nvidia686 = BooleanVar()
	self.nvidia486 = BooleanVar()
	self.nvidiaK7 = BooleanVar()
	self.ati = BooleanVar()
	self.ppracer = BooleanVar()
	self.fonts = BooleanVar()
	self.numlockx = BooleanVar()


		#_____________________________________________________________________

	############### DESKTOP ###############

        page = notebook.add('Desktop')
        notebook.tab('Desktop').focus_set()
        group = Pmw.Group(page, tag_text = 'Desktop')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b = Tkinter.Checkbutton(group.interior(), text = 'Gnome Desktop Environment', variable = self.gnome)
        b.grid(row = 0, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'K Desktop Environment', variable = self.kde)
        b.grid(row = 1, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'XFce Desktop Environment', variable = self.xfce)
        b.grid(row = 2, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Icedove Mail Client', variable = self.icedove)
        b.grid(row = 3, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Sylpheed Claws Mail Client', variable = self.sylpheed)
        b.grid(row = 4, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Abiword Word Processor', variable = self.abiword)
        b.grid(row = 5, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Wine (emulator for Windows apps)', variable = self.wine)
        b.grid(row = 6, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'gDesklets widgets', variable = self.gdesklets)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Gnomebaker CD/DVD Burner', variable = self.gnomebaker)
        b.grid(row = 1, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'K3b CD/DVD burner', variable = self.k3b)
        b.grid(row = 2, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Photo tools', variable = self.photo)
        b.grid(row = 3, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Beryl/AIGLX 3D Desktop', variable = self.beryl)
        b.grid(row = 4, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'GoogleEarth 4', variable = self.googleearth)
        b.grid(row = 5, column = 1, sticky = W)


        # The "Controls" contents of the page.
        group = Pmw.Group(page, tag_text = 'Controls')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b = Tkinter.Button(group.interior(), text = 'About', command = self.about)
        b.grid(row = 0, column = 0, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Start', command = self.install)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Button(group.interior(),text = 'Exit', command = root.destroy)
        b.grid(row = 0, column = 2, sticky = W)

		#_____________________________________________________________________

	############### INTERNET ###############

        page = notebook.add('Internet')
        group = Pmw.Group(page, tag_text = 'Internet')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
	b = Tkinter.Checkbutton(group.interior(), text = 'Swiftfox Web Browser', variable = self.swiftfox)
        b.grid(row = 0, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'Opera Web Browser', variable = self.opera)
        b.grid(row = 1, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'Konqueror Browser', variable = self.konq)
        b.grid(row = 2, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'Flash 9 Plugin', variable = self.flash9)
        b.grid(row = 3, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'gFTP FTP client', variable = self.gftp)
        b.grid(row = 4, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'X-Chat IRC client', variable = self.xchat)
        b.grid(row = 5, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Gaim IM client', variable = self.gaim)
        b.grid(row = 6, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Skype IM/Voice client', variable = self.skype)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Nicotine P2P client', variable = self.nicotine)
        b.grid(row = 1, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'FrostwireP2P client', variable = self.frostwire)
        b.grid(row = 2, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Azureus torrent client', variable = self.azureus)
        b.grid(row = 3, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Sun Java RE Plugin', variable = self.java)
        b.grid(row = 4, column = 1, sticky = W)



        # The "Controls" contents of the page.
        group = Pmw.Group(page, tag_text = 'Controls')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b = Tkinter.Button(group.interior(), text = 'About', command = self.about)
        b.grid(row = 0, column = 0, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Start', command = self.install)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Exit', command = root.destroy)
        b.grid(row = 0, column = 2, sticky = W)

		#_____________________________________________________________________

	############### MULTIMEDIA ###############

        page = notebook.add('Multimedia')
        group = Pmw.Group(page, tag_text = 'Multimedia')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b = Tkinter.Checkbutton(group.interior(), text = 'Macromedia Flash Player', variable = self.macro)
        b.grid(row = 0, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Myth TV', variable = self.myth)
        b.grid(row = 1, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Listen Media Player', variable = self.listen)
        b.grid(row = 2, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'VLC Mozilla Plugin', variable = self.vlc)
        b.grid(row = 3, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'RealPlayer 10', variable = self.realplayer)
        b.grid(row = 4, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Jokosher Audio Recording', variable = self.jokosher)
        b.grid(row = 5, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Audacity Audio Editing', variable = self.audacity)
        b.grid(row = 6, column = 0, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Hydrogen Drum synth', variable = self.hydrogen)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'EasyTag MP3 tag editor', variable = self.easytag)
        b.grid(row = 1, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Banshee Music Player', variable = self.banshee)
        b.grid(row = 2, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'xmms Music Player', variable = self.xmms)
        b.grid(row = 3, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Amarok Jukebox', variable = self.amarok)
        b.grid(row = 4, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'Songbird Music Player', variable = self.songbird)
        b.grid(row = 5, column = 1, sticky = W)
        b = Tkinter.Checkbutton(group.interior(), text = 'libdvdcss codec', variable = self.libdvdcss)
        b.grid(row = 6, column = 1, sticky = W)


        # The "Controls" contents of the page.
	group = Pmw.Group(page, tag_text = 'Controls')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b = Tkinter.Button(group.interior(), text = 'About', command = self.about)
        b.grid(row = 0, column = 0, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Start', command = self.install)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Exit', command = root.destroy)
        b.grid(row = 0, column = 2, sticky = W)

		#_____________________________________________________________________

	############### MISC ###############

        page = notebook.add('Miscellaneous')
        group = Pmw.Group(page, tag_text = 'Miscellaneous')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
	b = Tkinter.Checkbutton(group.interior(), text = 'nVidia driver (686)', variable = self.nvidia686)
        b.grid(row = 0, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'nVidia driver (486)', variable = self.nvidia486)
        b.grid(row = 1, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'nVidia driver (K7)', variable = self.nvidiaK7)
        b.grid(row = 2, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'ATI driver (fglrx)', variable = self.ati)
        b.grid(row = 3, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'Planet Penguin Racer', variable = self.ppracer)
        b.grid(row = 4, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'Fancy Font Packages', variable = self.fonts)
        b.grid(row = 5, column = 0, sticky = W)
	b = Tkinter.Checkbutton(group.interior(), text = 'Turn on Numlock (numlockx)', variable = self.numlockx)
        b.grid(row = 6, column = 0, sticky = W)

        # The "Controls" contents of the page.
	group = Pmw.Group(page, tag_text = 'Controls')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b = Tkinter.Button(group.interior(), text = 'About', command = self.about)
        b.grid(row = 0, column = 0, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Start', command = self.install)
        b.grid(row = 0, column = 1, sticky = W)
        b = Tkinter.Button(group.interior(), text = 'Exit', command = root.destroy)
        b.grid(row = 0, column = 2, sticky = W)

		#_____________________________________________________________________

        notebook.setnaturalsize()

		#_____________________________________________________________________

root = Tk()
root.title("Hakix v1.0 Easy Installer for Debian")
root.option_add('*font', '"Helvetica" -12')
app = Hakix(root)
root.mainloop()
